﻿using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	// Token: 0x020017CA RID: 6090
	internal class XMentorshipCandidatesView : DlgBase<XMentorshipCandidatesView, XMentorshipCandidatesBehavior>
	{
		// Token: 0x17003894 RID: 14484
		// (get) Token: 0x0600FC37 RID: 64567 RVA: 0x003AC6BC File Offset: 0x003AA8BC
		public override string fileName
		{
			get
			{
				return "GameSystem/TeacherPupilInvitation";
			}
		}

		// Token: 0x17003895 RID: 14485
		// (get) Token: 0x0600FC38 RID: 64568 RVA: 0x003AC6D4 File Offset: 0x003AA8D4
		public override int layer
		{
			get
			{
				return 1;
			}
		}

		// Token: 0x17003896 RID: 14486
		// (get) Token: 0x0600FC39 RID: 64569 RVA: 0x003AC6E8 File Offset: 0x003AA8E8
		public override int group
		{
			get
			{
				return 1;
			}
		}

		// Token: 0x17003897 RID: 14487
		// (get) Token: 0x0600FC3A RID: 64570 RVA: 0x003AC6FC File Offset: 0x003AA8FC
		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		// Token: 0x0600FC3B RID: 64571 RVA: 0x003AC70F File Offset: 0x003AA90F
		protected override void Init()
		{
			this.InitProperties();
		}

		// Token: 0x0600FC3C RID: 64572 RVA: 0x003AC719 File Offset: 0x003AA919
		protected override void OnUnload()
		{
			base.OnUnload();
		}

		// Token: 0x0600FC3D RID: 64573 RVA: 0x003AC723 File Offset: 0x003AA923
		public override void RegisterEvent()
		{
			base.RegisterEvent();
		}

		// Token: 0x0600FC3E RID: 64574 RVA: 0x003AC730 File Offset: 0x003AA930
		protected override void OnShow()
		{
			base.OnShow();
			this.RefreshTitleAndDownBtn();
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOp_Get, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
					if (flag3)
					{
						XMentorshipDocument.Doc.SendToGetMyApplyMasterInfo(false);
					}
					else
					{
						XMentorshipDocument.Doc.SendToGetMyApplyPupilsInfo(false);
					}
				}
			}
		}

		// Token: 0x0600FC3F RID: 64575 RVA: 0x003AC7B0 File Offset: 0x003AA9B0
		private void RefreshTitleAndDownBtn()
		{
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				base.uiBehaviour.titleContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipApply"));
				base.uiBehaviour.btnContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipClear"));
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					base.uiBehaviour.titleContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipRecommend"));
					base.uiBehaviour.btnContent.SetText(XSingleton<XStringTable>.singleton.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
				}
			}
			base.uiBehaviour.ClearBtn.SetEnable(true, false);
			base.uiBehaviour.btnContent.SetText(XStringDefineProxy.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
		}

		// Token: 0x0600FC40 RID: 64576 RVA: 0x003AC894 File Offset: 0x003AAA94
		protected override void OnHide()
		{
			base.OnHide();
			XMentorshipDocument.Doc.ResetCandidatesView();
		}

		// Token: 0x0600FC41 RID: 64577 RVA: 0x003AC8AC File Offset: 0x003AAAAC
		public void RefreshUI()
		{
			int canidatesShowMsgCount = XMentorshipDocument.Doc.GetCanidatesShowMsgCount();
			base.uiBehaviour.WrapContent.SetContentCount(canidatesShowMsgCount, false);
			base.uiBehaviour.ScrollView.ResetPosition();
		}

		// Token: 0x0600FC42 RID: 64578 RVA: 0x003AC8E9 File Offset: 0x003AAAE9
		public void RefreshAllVisible()
		{
			base.uiBehaviour.WrapContent.RefreshAllVisibleContents();
		}

		// Token: 0x0600FC43 RID: 64579 RVA: 0x003AC900 File Offset: 0x003AAB00
		public void RefreshCDTimeLabel(int leftTime)
		{
			bool flag = leftTime > 0;
			if (flag)
			{
				base.uiBehaviour.ClearBtn.SetEnable(false, false);
				base.uiBehaviour.btnContent.SetText(string.Format(XStringDefineProxy.GetString("FRIEND_ADDDLG_COUNTDOWN_FMT"), leftTime));
			}
			else
			{
				base.uiBehaviour.ClearBtn.SetEnable(true, false);
				base.uiBehaviour.btnContent.SetText(XStringDefineProxy.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
			}
		}

		// Token: 0x0600FC44 RID: 64580 RVA: 0x003AC984 File Offset: 0x003AAB84
		private void InitProperties()
		{
			base.uiBehaviour.CloseBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseDialog));
			base.uiBehaviour.ClearBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClearNews));
			base.uiBehaviour.WrapContent.RegisterItemInitEventHandler(new WrapItemInitEventHandler(this.OnWrapContentItemInit));
			base.uiBehaviour.WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnWrapContentItemUpdate));
		}

		// Token: 0x0600FC45 RID: 64581 RVA: 0x003ACA08 File Offset: 0x003AAC08
		private bool OnClearNews(IXUIButton button)
		{
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Clear, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
					if (flag3)
					{
						XMentorshipDocument.Doc.SendToGetMyApplyMasterInfo(true);
					}
					else
					{
						XMentorshipDocument.Doc.SendToGetMyApplyPupilsInfo(true);
					}
				}
			}
			return true;
		}

		// Token: 0x0600FC46 RID: 64582 RVA: 0x003ACA80 File Offset: 0x003AAC80
		private bool OnCloseDialog(IXUIButton button)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		// Token: 0x0600FC47 RID: 64583 RVA: 0x003ACA9C File Offset: 0x003AAC9C
		private void OnWrapContentItemUpdate(Transform itemTransform, int index)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend);
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo(index);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				IXUILabel ixuilabel = itemTransform.Find("level").GetComponent("XUILabel") as IXUILabel;
				ixuilabel.SetText(candidateMsgShowInfo.roleInfo.level.ToString());
				uint titleID = (candidateMsgShowInfo.roleInfo.outlook != null && candidateMsgShowInfo.roleInfo.outlook.title != null) ? candidateMsgShowInfo.roleInfo.outlook.title.titleID : 0U;
				IXUILabelSymbol ixuilabelSymbol = itemTransform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
				ixuilabelSymbol.InputText = XTitleDocument.GetTitleWithFormat(titleID, candidateMsgShowInfo.roleInfo.name);
				IXUISprite ixuisprite = itemTransform.Find("head").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon2((int)((int)candidateMsgShowInfo.roleInfo.type % /*(RoleType)*/10));
				IXUISprite ixuisprite2 = itemTransform.Find("Profession").GetComponent("XUISprite") as IXUISprite;
				ixuisprite2.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfIcon((int)((int)candidateMsgShowInfo.roleInfo.type % /*(RoleType)*/10));
				IXUILabel ixuilabel2 = itemTransform.Find("PromiseWords").GetComponent("XUILabel") as IXUILabel;
				ixuilabel2.SetText(candidateMsgShowInfo.promiseWords);
				IXUILabel ixuilabel3 = itemTransform.Find("Mentorship/T").GetComponent("XUILabel") as IXUILabel;
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
				if (flag2)
				{
					ixuibutton.ID = (ulong)((long)index);
					ixuibutton2.ID = (ulong)((long)index);
				}
				else
				{
					ixuibutton3.ID = candidateMsgShowInfo.roleInfo.roleID;
					bool applied = candidateMsgShowInfo.applied;
					if (applied)
					{
						ixuibutton3.SetEnable(false, false);
						ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("CHAT_SENT"));
					}
					else
					{
						ixuibutton3.SetEnable(true, false);
						bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
						if (flag3)
						{
							ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipMaster"));
						}
						else
						{
							ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipPupil"));
						}
					}
				}
			}
		}

		// Token: 0x0600FC48 RID: 64584 RVA: 0x000FEEFC File Offset: 0x000FD0FC
		private void OnStartPlayAudio(IXUISprite uiSprite)
		{
		}

		// Token: 0x0600FC49 RID: 64585 RVA: 0x003ACD84 File Offset: 0x003AAF84
		private void OnStopSignPlay(object ob)
		{
			IXUISpriteAnimation ixuispriteAnimation = (IXUISpriteAnimation)ob;
			bool flag = ixuispriteAnimation != null;
			if (flag)
			{
				ixuispriteAnimation.SetFrameRate(0);
				ixuispriteAnimation.Reset();
			}
		}

		// Token: 0x0600FC4A RID: 64586 RVA: 0x003ACDB4 File Offset: 0x003AAFB4
		private void UpdateOpBtnState(Transform itemTransform)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend);
		}

		// Token: 0x0600FC4B RID: 64587 RVA: 0x000FEEFC File Offset: 0x000FD0FC
		private void OnPlayPromiseVoice(IXUISprite uiSprite)
		{
		}

		// Token: 0x0600FC4C RID: 64588 RVA: 0x003ACE60 File Offset: 0x003AB060
		private void OnWrapContentItemInit(Transform itemTransform, int index)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickAcceptCandidate));
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickRefuseCandidate));
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnMentorshipClicked));
		}

		// Token: 0x0600FC4D RID: 64589 RVA: 0x003ACEF8 File Offset: 0x003AB0F8
		private bool OnMentorshipClicked(IXUIButton button)
		{
			bool flag = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
			if (flag)
			{
				XMentorshipDocument.Doc.SendMentorRelationOp(MentorRelationOpType.MentorRelationOp_ApplyMaster, button.ID, 0);
			}
			else
			{
				XMentorshipDocument.Doc.SendMentorRelationOp(MentorRelationOpType.MentorRelationOp_ApplyStudent, button.ID, 0);
			}
			return true;
		}

		// Token: 0x0600FC4E RID: 64590 RVA: 0x003ACF44 File Offset: 0x003AB144
		private bool OnClickRefuseCandidate(IXUIButton button)
		{
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo((int)button.ID);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Reject, candidateMsgShowInfo.roleInfo.roleID, candidateMsgShowInfo.msgType, 0, false);
			}
			return true;
		}

		// Token: 0x0600FC4F RID: 64591 RVA: 0x003ACF94 File Offset: 0x003AB194
		private bool OnClickAcceptCandidate(IXUIButton button)
		{
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo((int)button.ID);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, candidateMsgShowInfo.roleInfo.roleID, candidateMsgShowInfo.msgType, 0, false);
			}
			return true;
		}
	}
}
